package com.ht.medicaltreatment.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.ItemListBean

class ItemListAdapter(checkId:Int,list:MutableList<ItemListBean>):BaseQuickAdapter<ItemListBean,BaseViewHolder>(R.layout.item_layout,list) {
    private var checkId = checkId

    fun setCheckId(checkId:Int){
        this.checkId = checkId
    }

    override fun convert(holder: BaseViewHolder, item: ItemListBean) {
        val tvName = holder.getView<TextView>(R.id.tvName)
        tvName.text = item.name
        if(item.id == checkId){
            tvName.setBackgroundColor(context.getColor(R.color.blue))
            tvName.setTextColor(Color.WHITE)
        }else{
            if(item.disable.isEmpty()){
                tvName.setBackgroundColor(context.getColor(R.color.white))
                tvName.setTextColor(Color.BLACK)
            }else{
                tvName.setBackgroundColor(context.getColor(R.color.colorTextGray))
                tvName.setTextColor(context.getColor(R.color.color66))
            }
        }
        if(getItemPosition(item) == 0){
            holder.setGone(R.id.line,true)
        }else{
            holder.setGone(R.id.line,false)
        }
    }
}